#include<stdio.h>
#include<string.h>
#define MAXN 19
int num[MAXN];

void OutputBinaryTree(int n, int k, bool s) {
    if (n == 0) return;
    int i, j, sum;
    for (i = sum = 0, j=num[n-1]; sum + j < k; sum += j, ++i, j = num[i] * num[n-1-i]) {}
    k -= sum;
    if(s) printf("(");
    OutputBinaryTree(i, (k + num[n-1-i] - 1) / num[n-1-i], true);
    printf("X");
    j =  k % num[n-1-i];
    OutputBinaryTree(n-1-i, j == 0 ? num[n-1-i] : j, true);
    if(s) printf(")");
}

int main(){
    int i, j, k;
    memset(num, 0, sizeof(int) * MAXN);
    num[0] = num[1] = 1;
    for (i = 2; i < MAXN; i++) 
	for (j = 0; j < i; j++)
	    num[i] += num[j] * num[i-1-j];

    while(scanf("%d", &k) && k) {
	for (i = 1; k > num[i]; k -= num[i], ++i){}
	OutputBinaryTree(i, k, false);
	printf("\n");
    }
    return 0;
}
